type DictType = Array<{ label: string; value: string }>;

export const sexTypeOption: DictType = [
  { value: '0', label: '女' },
  { value: '1', label: '男' },
];

export const roleTypeOption: DictType = [
  { value: 'jl', label: '健身教练' },
  { value: 'yys', label: '营养师' },
  { value: 'user', label: '用户' },
];

/**
 * 根据value和字典获取label
 * @param value
 * @param dict
 * @returns
 */
export function getLabelByValue(value: string, dict: DictType): string {
  const option = dict.find((option) => option.value === value);
  return option ? option.label : '';
}

/**
 * 给字符串加后缀
 * @param str
 * @param suffix
 * @returns
 */
export const addSuffix = (str, suffix) => {
  if (!str) return '';
  if (!str.endsWith(suffix)) {
    return str + suffix;
  }
  return str;
};
